package csel.controller.bindings;

import java.awt.event.KeyEvent;
import csel.controller.enums.ActionEnum;

public class KeyBindings extends AbstractBindings<Integer, ActionEnum>
{
	/**
	 * This class uses a concurrent hashmap parameterized with Integer keys and
	 * ActionEnum values, it has a default set of bindings and allows the
	 * bindings to be updated and for values to be retrieved based off of a
	 * certain key.
	 */
	private static KeyBindings instance;

	/**
	 * The constructor for this class takes no parameters. It adds all the default bindings we want
	 * our game to have. As new actions that need bindings are created they
	 * need to be added to this constructor.
	 */
	private KeyBindings()
	{
		super();
		updateBinding(KeyEvent.VK_R,		ActionEnum.TOGGLE_MENU);
		updateBinding(KeyEvent.VK_LEFT, 	ActionEnum.MOVE_WEST);
		updateBinding(KeyEvent.VK_DOWN, 	ActionEnum.MOVE_SOUTH);
		updateBinding(KeyEvent.VK_RIGHT, 	ActionEnum.MOVE_EAST);
		updateBinding(KeyEvent.VK_UP, 		ActionEnum.MOVE_NORTH);
		updateBinding(KeyEvent.VK_NUMPAD1, 	ActionEnum.MOVE_SOUTHWEST);
		updateBinding(KeyEvent.VK_NUMPAD2, 	ActionEnum.MOVE_SOUTH);
		updateBinding(KeyEvent.VK_NUMPAD3, 	ActionEnum.MOVE_SOUTHEAST);
		updateBinding(KeyEvent.VK_NUMPAD4,	ActionEnum.MOVE_WEST);
		updateBinding(KeyEvent.VK_NUMPAD6, 	ActionEnum.MOVE_EAST);
		updateBinding(KeyEvent.VK_NUMPAD7, 	ActionEnum.MOVE_NORTHWEST);
		updateBinding(KeyEvent.VK_NUMPAD8, 	ActionEnum.MOVE_NORTH);
		updateBinding(KeyEvent.VK_NUMPAD9, 	ActionEnum.MOVE_NORTHEAST);
		updateBinding(KeyEvent.VK_1, 		ActionEnum.SLOT_1);
		updateBinding(KeyEvent.VK_2, 		ActionEnum.SLOT_2);
		updateBinding(KeyEvent.VK_3, 		ActionEnum.SLOT_3);
		updateBinding(KeyEvent.VK_4, 		ActionEnum.SLOT_4);
		updateBinding(KeyEvent.VK_5, 		ActionEnum.SLOT_5);
		updateBinding(KeyEvent.VK_6, 		ActionEnum.SLOT_6);
		updateBinding(KeyEvent.VK_7, 		ActionEnum.SLOT_7);
		updateBinding(KeyEvent.VK_8, 		ActionEnum.SLOT_8);
		updateBinding(KeyEvent.VK_9, 		ActionEnum.SLOT_9);
		updateBinding(KeyEvent.VK_0, 		ActionEnum.SLOT_0);
		updateBinding(KeyEvent.VK_E, 		ActionEnum.EQUIPMENT);
		updateBinding(KeyEvent.VK_I, 		ActionEnum.INVENTORY);
		updateBinding(KeyEvent.VK_T, 		ActionEnum.SKILLS);
		updateBinding(KeyEvent.VK_Z,		ActionEnum.LEAVE_VEHICLE);
		updateBinding(KeyEvent.VK_EQUALS,	ActionEnum.ROTATE_SLOTS);
		updateBinding(KeyEvent.VK_MINUS, 	ActionEnum.CHANGE_SUBVIEW);
		updateBinding(KeyEvent.VK_CONTROL, 	ActionEnum.ATTACK);
		updateBinding(KeyEvent.VK_ESCAPE, 	ActionEnum.RETURN);
		updateBinding(new Integer(-1), 		ActionEnum.RELEASE);
	}

	public static KeyBindings getInstance()
	{
		if (instance == null)
		{
			instance = new KeyBindings();
		}
		return instance;
	}
}